Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
DocumentNotFoundError: No document found for query"{id:xxx}"

hello I have a discord bot and I started to do a marriage and divorce command the case is that when I try to delete the user from the db I get the error

DocumentNotFoundError: No document found for query "{ _id: new ObjectId("61ec3c66cb5991d616c6032d") }" on model "casados"

this is my model

const  mongoose = require("mongoose")
const casados = mongoose.Schema({
    pareja1: String,
    pareja2: String
})
module.exports = mongoose.model("casados", casados)

my code in the marry command is

look for the model

let modelo = await casados.findOne({ $or: [{pareja1: interaction.user.id}, {pareja2: interaction.user.id}]})

If it doesn't find it, create a new one.

if(!modelo) modelo = new casados({
         pareja1: interaction.user.id,
         pareja2: pareja.id
       })
       await modelo.save()

then on my command divorce

look for the model again

let modelo = await casados.findOne({ $or: [{pareja1: interaction.user.id}, {pareja2: interaction.user.id}]})

and delete it

await casados.findOneAndDelete({
        $or: [
            {pareja1: interaction.user.id},
            {pareja2: interaction.user.id}
        ]}).catch(e=> { console.log(e)})
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!